/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Damian
 */
@Entity
@Table(name = "hourly_offer")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HourlyOffer.findAll", query = "SELECT h FROM HourlyOffer h"),
    @NamedQuery(name = "HourlyOffer.findByIdHourlyOffer", query = "SELECT h FROM HourlyOffer h WHERE h.idHourlyOffer = :idHourlyOffer"),
    @NamedQuery(name = "HourlyOffer.findByName", query = "SELECT h FROM HourlyOffer h WHERE h.name = :name"),
    @NamedQuery(name = "HourlyOffer.findByStartHour", query = "SELECT h FROM HourlyOffer h WHERE h.startHour = :startHour"),
    @NamedQuery(name = "HourlyOffer.findByEndHour", query = "SELECT h FROM HourlyOffer h WHERE h.endHour = :endHour")})
public class HourlyOffer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_HOURLY_OFFER")
    private Integer idHourlyOffer;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Column(name = "START_HOUR")
    @Temporal(TemporalType.TIME)
    private Date startHour;
    @Basic(optional = false)
    @NotNull
    @Column(name = "END_HOUR")
    @Temporal(TemporalType.TIME)
    private Date endHour;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idHourly")
    private Collection<OfferHourly> offerHourlyCollection;

    public HourlyOffer() {
    }

    public HourlyOffer(Integer idHourlyOffer) {
        this.idHourlyOffer = idHourlyOffer;
    }

    public HourlyOffer(Integer idHourlyOffer, String name, Date startHour, Date endHour) {
        this.idHourlyOffer = idHourlyOffer;
        this.name = name;
        this.startHour = startHour;
        this.endHour = endHour;
    }

    public Integer getIdHourlyOffer() {
        return idHourlyOffer;
    }

    public void setIdHourlyOffer(Integer idHourlyOffer) {
        this.idHourlyOffer = idHourlyOffer;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getStartHour() {
        return startHour;
    }

    public void setStartHour(Date startHour) {
        this.startHour = startHour;
    }

    public Date getEndHour() {
        return endHour;
    }

    public void setEndHour(Date endHour) {
        this.endHour = endHour;
    }

    @XmlTransient
    public Collection<OfferHourly> getOfferHourlyCollection() {
        return offerHourlyCollection;
    }

    public void setOfferHourlyCollection(Collection<OfferHourly> offerHourlyCollection) {
        this.offerHourlyCollection = offerHourlyCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idHourlyOffer != null ? idHourlyOffer.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HourlyOffer)) {
            return false;
        }
        HourlyOffer other = (HourlyOffer) object;
        if ((this.idHourlyOffer == null && other.idHourlyOffer != null) || (this.idHourlyOffer != null && !this.idHourlyOffer.equals(other.idHourlyOffer))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.HourlyOffer[ idHourlyOffer=" + idHourlyOffer + " ]";
    }
    
}
